package org.example.tree;

/**
 * @author liyishan
 * @date 2024/5/15 14:04
 * @apiNote
 */

public class Test00538ConvertBST {

    int sum = 0;
    public TreeNode convertBST(TreeNode root) {
        if(root != null){
            convertBST(root.right);
            sum += root.val;
            root.val =sum;
            convertBST(root.left);
        }
        return root;
    }
}
